/*
 * Copyright 2009 Gary Brown
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 *
 * Change History:
 * 18 Mar 2009 : Initial version created by gary
 */
package org.betonthemove.ui.android;

import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.webkit.WebView;

public class LicenseDialog extends android.app.AlertDialog
								implements OnClickListener {

	private static final String NOT_ACCEPT_LABEL = "Don't Accept";
	private static final String ACCEPT_LABEL = "Accept";
	private static final String LICENSE_PATH = "file:///android_asset/LICENSE.html";

	public LicenseDialog(Context context) {
		super(context);
		
		setCancelable(false);
		
		WebView view=new WebView(context);
		view.loadUrl(LICENSE_PATH);
		
		setView(view);
		
		setButton(ACCEPT_LABEL, this);
		
		setButton2(NOT_ACCEPT_LABEL, this);
	}

	public void onClick(DialogInterface dialog, int which) {
		if (which == BUTTON1) {
			dialog.dismiss();
		} else if (which == BUTTON2) {
			dialog.cancel();
		}
	}			
}
